import { createApp } from 'vue'
import App from './App.vue'
import "@/assets/less/index.less"
import router from "./router/index.js";
import { createPinia } from 'pinia'
import api from "./api/api.js";
import ElementPlus from "element-plus"
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import "@/api/mock.js"
import 'default-passive-events'
import {useAllDataStore} from "./stores/index.js";
const pinia = createPinia();
const app=createApp(App);
function isRoute(to) {
    return router.getRoutes().filter(item=>item.path===to.path).length>0
}
router.beforeEach((to, from)=>{
    if (to.path!=="/login"&&!store.state.token){
        return {name:"login"}
    }
})
app.config.globalProperties.$api=api;
app.use(pinia);
const store=useAllDataStore();
store.addMenu(router,"refresh");
app.use(ElementPlus);
app.use(router).mount('#app');
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
